﻿<%@ page contentType="text/html;charset=utf-8"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="com.tjtt.tdm.system.action.OrganizationAction"%>
<%@page import="com.tjtt.tdm.system.bean.Organization"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page import="java.util.List"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>用户管理列表</title>
        <%@ include file="../jslib/jquerylib.jsp" %>
        <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
        <link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="<%=request.getContextPath() %>/jslib/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
        <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/ztree/js/jquery.ztree.core-3.5.js"></script>
        <!-- 结果信息返回 -->
         <c:if test="${requestScope.message!=null}">
             <script type="text/javascript">
                  alert('<c:out value="${requestScope.message}"></c:out>');
                  window.close();
             </script>
         </c:if>
         <style type="text/css">
            body, html{
             overflow-x:hidden 
            }
        </style>
        <script type="text/javascript">
            var treeObj;
            var flag = "1";
            var delflag = "1";
            var chaflag = "1";
            var orgParentId = "";
            var tree_sel=null;
            var common_contextPath="<%=common_contextPath%>";
            var common_basePath="<%=common_basePath%>";
             var common_width = window.screen.width-0;
            var common_height = window.screen.height-420;
            $(document).ready(function(){      
            	//高级搜索需要的js
				 buttonStatus=1;
				 $("#flip").click(function(){
					if(buttonStatus==1){
						$("#panel").slideToggle("slow");
						$("#flip").toggleClass("btnStatus2");
						buttonStatus=1;
					}
					else{
						$("#panel").slideUp("slow");
						$("#flip").toggleClass("btnStatus2");
					}
			     });
				 //高级搜索结束
                $("#gridTable").jqGrid({
                    url:common_contextPath+'/system/searchUsers.action',
                    datatype: "json",
                    height: common_height+20,
	                 width:common_width-570,
                    colNames:['编号','用户名','姓名','性别','岗位','所属组织','用户状态','锁定状态'],
                    colModel:[
                        {name: 'userid', index: 'userid',width:60, sorttype:"int",hidden:true,hidedlg:true},
                        {name: 'loginname', index: 'loginname', width:100},
                        {name: 'username', index: 'username', width:60},
                        {name: 'sexLabel', index: 'sex', width:50,hidden:true},
                        {name: 'jobName', index: 'jobName', width:220}, 
                        {name: 'organization.orgName', index: 'organization.orgName', width:120}, 
                        {name: 'activeLabel', index: 'active', width:80},
                        {name: 'lockFlagLabel', index: 'lockFlag', width:60}
                    ],   
                    shrinkToFit:false,
                    sortname:'userid',
                    sortorder:'desc',
                    viewrecords:true,
                    multiselect: true, // 是否显示复选框
                    multiboxonly : true, 
                    rownumbers: false,//显示行号
                    editable:true, 
                    rowNum:<%=session.getAttribute("SYS_PAGECOUNT")%>,
                    rowList:[15,20,50,200,500],
                    toolbar: [false,"top"],
                    jsonReader: {
                        root:"rows",        // 数据行（默认为：rows）
                        page: "page",   // 当前页
                        total: "total",  // 总页数
                        records: "records",  // 总记录数
                        repeatitems : false     // 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
                    },
                    prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
                    pager:"#gridPager",
                    caption: "用户管理列表"
                });
                 jQuery("#gridTable").jqGrid('navGrid','#gridPager',{add:false,edit:false,del:false,search:false,refresh:false});
                    
            });
            
            //刷新
            function reload(){
                location.reload(); 
            }
                         
            //--查询名称 高亮 开始---------------------------------------------------------------------
            function focusKey(e) {
                if (key.hasClass("empty")) {
                    key.removeClass("empty");
                }
            }
            function blurKey(e) {
                if (key.get(0).value === "") {
                    key.addClass("empty");
                }
            }
            var lastValue = "", nodeList = [], fontCss = {};
            
            function searchNode(e) {
                var zTree = $.fn.zTree.getZTreeObj("tree");
                var value = $.trim(key.get(0).value);
                var keyType = "";
                keyType = "name";
                if (lastValue === value) return;
                lastValue = value;
                if (value === "") return;
                updateNodes(false);
                nodeList = zTree.getNodesByParamFuzzy(keyType, value);
                updateNodes(true);
    
            }
            function updateNodes(highlight) {
                var zTree = $.fn.zTree.getZTreeObj("tree");
                for( var i=0, l=nodeList.length; i<l; i++) {
                    nodeList[i].highlight = highlight;
                    zTree.updateNode(nodeList[i]);
                }
            }
            function getFontCss(treeId, treeNode) {
                return (!!treeNode.highlight) ? {color:"#A60000", "font-weight":"bold"} : {color:"#333", "font-weight":"normal"};
            }
            function filter(node) {
                return !node.isParent && node.isFirstNode;
            }
    
            var key;
            $(document).ready(function(){                    	
                $.fn.zTree.init($("#tree"), setting, zNodes);
                key = $("#key");
                key.bind("focus", focusKey)
                .bind("blur", blurKey)
                .bind("propertychange", searchNode)
                .bind("input", searchNode); 
            });
            //--查询名称 高亮 结束---------------------------------------------------------------------
                
            <%
                ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(application);
                OrganizationAction organization = (OrganizationAction)context.getBean("organizationAction");
                List result = organization.getOrganizationTree();
                String treeNode = "";
                String orgParentId = "";
                String orgId = "" ;
                String orgName = "";
                String orgDesc = "";
                for(int i=0;i<result.size();i++){
                    Organization o = (Organization)result.get(i);
                    orgId = o.getOrgId().toString();
                    orgName = (String)o.getOrgName();
                    orgDesc = (String)o.getOrgDesc();
                    orgParentId = o.getOrgParentId().toString();
                    orgDesc = o.getOrgDesc()==null?"":o.getOrgDesc();
                    if("1".equals(orgId)){
                        treeNode +="{\"id\":"+orgId+",\"pId\":"+orgParentId+",\"name\":\""+orgName+"\",\"title\":\""+orgDesc+"\",\"open\":true},";  
                    }else{
                        treeNode +="{\"id\":"+orgId+",\"pId\":"+orgParentId+",\"name\":\""+orgName+"\",\"title\":\""+orgDesc+"\",\"open\":false},"; 
                    }
                    
                }
                String newTreeNode=treeNode.substring(0,treeNode.length()-1);   
                System.out.println(newTreeNode);
            %>
            var setting = {
                treeId:'tree',
                callback: {
                        onClick: zTreeOnClick,
                        beforeCollapse: beforeCollapse,
                        beforeExpand: beforeExpand,
                        onCollapse: onCollapse,
                        onExpand: onExpand
                    },
                view: {
                    selectedMulti: false
                },
                data: {
                    key: {
                        title: "name"
                    },
                    simpleData: {
                        enable: true,
                        idKey: "id",
                        pIdKey: "pId",
                        rootPId: -1
                    }
                                
                },
                view: {
                    fontCss: getFontCss
                }
            };
            function zTreeOnClick(event, treeId, treeNode) {
                tree_sel = treeNode;
                var id=treeNode.id;
                 var params = {  
                "id" : encodeURIComponent(id)
           	 	};
                 var postData = $("#gridTable").jqGrid("getGridParam", "postData");
	             $.extend(postData, params);  //(9)将postData中的查询参数覆盖为空值
             
	            jQuery("#gridTable").jqGrid('setGridParam',
	            {
	                url:common_contextPath+'/system/findUserByOrgId.action'
	            }).trigger("reloadGrid", [{page:1}]); 
            };

            var zNodes =[
                    <%=newTreeNode%>
            ];
        
            function showIconForTree(tetid, treeNode) {
                return !treeNode.isParent;
            };
            //展开/关闭按钮 开始-----------------------------------------------------------------------
            var log, className = "dark";
            function beforeCollapse(treeId, treeNode) {
                className = (className === "dark" ? "":"dark");
                showLog("[ "+getTime()+" beforeCollapse ]&nbsp;&nbsp;&nbsp;&nbsp;" + treeNode.name );
                return (treeNode.collapse !== false);
            }
            function onCollapse(event, treeId, treeNode) {
                showLog("[ "+getTime()+" onCollapse ]&nbsp;&nbsp;&nbsp;&nbsp;" + treeNode.name);
            }       
            function beforeExpand(treeId, treeNode) {
                className = (className === "dark" ? "":"dark");
                showLog("[ "+getTime()+" beforeExpand ]&nbsp;&nbsp;&nbsp;&nbsp;" + treeNode.name );
                return (treeNode.expand !== false);
            }
            function onExpand(event, treeId, treeNode) {
                showLog("[ "+getTime()+" onExpand ]&nbsp;&nbsp;&nbsp;&nbsp;" + treeNode.name);
            }
            function showLog(str) {
                if (!log) log = $("#log");
                log.append("<li class='"+className+"'>"+str+"</li>");
                if(log.children("li").length > 8) {
                    log.get(0).removeChild(log.children("li")[0]);
                }
            }
            function getTime() {
                var now= new Date(),
                h=now.getHours(),
                m=now.getMinutes(),
                s=now.getSeconds(),
                ms=now.getMilliseconds();
                return (h+":"+m+":"+s+ " " +ms);
            }
    
            function expandNode(e) {
                var zTree = $.fn.zTree.getZTreeObj("tree"),
                type = e.data.type,
                nodes = zTree.getSelectedNodes();
                if (type.indexOf("All")<0 && nodes.length == 0) {
                    alert("请先选择一个父节点");
                }
    
                if (type == "expandAll") {
                    zTree.expandAll(true);
                } else if (type == "collapseAll") {
                    zTree.expandAll(false);
                } else {
                    var callbackFlag = $("#callbackTrigger").attr("checked");
                    for (var i=0, l=nodes.length; i<l; i++) {
                        zTree.setting.view.fontCss = {};
                        if (type == "expand") {
                            zTree.expandNode(nodes[i], true, null, null, callbackFlag);
                        } else if (type == "collapse") {
                            zTree.expandNode(nodes[i], false, null, null, callbackFlag);
                        } else if (type == "toggle") {
                            zTree.expandNode(nodes[i], null, null, null, callbackFlag);
                        } else if (type == "expandSon") {
                            zTree.expandNode(nodes[i], true, true, null, callbackFlag);
                        } else if (type == "collapseSon") {
                            zTree.expandNode(nodes[i], false, true, null, callbackFlag);
                        }
                    }
                }
            }
            //展开/关闭按钮  结束---------------------------------------------------------------------
            $(document).ready(function(){           	
                treeObj = $.fn.zTree.init($("#tree"), setting, zNodes);
                $("#expandAllBtn").bind("click", {type:"expandAll"}, expandNode);
                $("#collapseAllBtn").bind("click", {type:"collapseAll"}, expandNode);
                
            }); 
            //ajax方法删除
           function deleteUser(){
                var ids = $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
                if(ids){
                    var delIds = [];
                    var idArray = ids.split(',');
                    for(var i=0;i<idArray.length;i++){
                        var id = idArray[i];
                        var row= $("#gridTable").jqGrid("getRowData", id);
                        var nodeId = row['userid'];
                        delIds.push(nodeId);
                        }   
                    }
                if (!ids) {
                alert("请先选择记录!");  
                   return false;  
                } 
               
                if(!confirm("是否确认删除？")){
                   return false;
                }
                 var params = {  
                    "ids": delIds.join()
                 };  
                var actionUrl = "delUser.action";  
                    $.ajax({  
                        url : actionUrl,  
                        type : "post", 
                        data : params,  
                        dataType : "json",  
                        cache : false,  
                    error : function(textStatus, errorThrown) {  
                        alert("系统ajax交互错误: " + textStatus.value);  
                    },  
                    success : function(data, textStatus) {  
                        refreshss();  
                        alert("删除成功！");   
                        
                    }  
                });
            }
            //上传证书主界面
        	function cerity(){
            	var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";   
	            if (!ids) {
	                alert("请先选择记录!");  
	                return false;  
	            }
	            if(ids.indexOf(",")!=-1){
	                  alert("只能选择一条记录!");  
	                  return false; 
	            }
            	var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
        		$.dialog({
				        id:'cerify',
				        //data:"{'userId':"+row.userid+"}",
				        title:'证书管理列表', 
				        content:'url:<%=request.getContextPath()%>/system/user_cerityIndex.jsp?userid='+row.userid,
				        okVal:false,//确定按钮文字
				        cancelVal:false,//取消按钮文字
				        min:true, //是否显示最小化按钮
				        max:false,//是否显示最大化按钮
				        fixed:false,//开启静止定位
				        lock:true,//开启锁屏
				        focus:true,//弹出窗口后是否自动获取焦点（4.2.0新增）
				        time:null,//设置对话框显示时间
				        resize:true,//是否允许用户调节尺寸
				        drag:true,//是否允许用户拖动位置
				        cache:false,//是否缓存iframe方式加载的窗口内容页
				        width: '780px',
				        height: 360
		        });
        	}
	      //下拉树选择组织
	       function beforeClick(treeId, treeNode) {
	           var check = (treeNode && !treeNode.isParent);
	          // if (!check) alert("请选择具体的组织机构");
	           return check;
	       }
        
	        function onClick(e, treeId, treeNode) {
	            var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
	            nodes = zTree.getSelectedNodes(),
	            v = "";
	            o = "";
	            nodes.sort(function compare(a,b){return a.id-b.id;});
	            for (var i=0, l=nodes.length; i<l; i++) {
	                v += nodes[i].name + ",";
	                o += nodes[i].id + ",";
	            }
	            if (v.length > 0 ) v = v.substring(0, v.length-1);
	            if (o.length > 0 ) o = o.substring(0, o.length-1);
	            var cityObj = $("#citySel");
	            var orgId = $("#orgId");
	            orgId.attr("value",o);
	            cityObj.attr("value", v);
	            hideMenu();
	        }
         	var treeIsLoad = false;
	        function showMenu() {
	            if(!treeIsLoad){
	                showOrgTree();
	            }    
	           
	            var cityObj = $("#citySel");
	            var cityOffset = $("#citySel").offset();
	            $("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
	
	            $("body").bind("mousedown", onBodyDown);
	        }
	        function hideMenu() {
	            $("#menuContent").fadeOut("fast");
	            $("body").unbind("mousedown", onBodyDown);
	        }
	        function onBodyDown(event) {
	            if (!(event.target.id == "citySel" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
	                hideMenu();
	            }
	        }
        
        	function showOrgTree(){
	            treeIsLoad = true;
	            var setting = {
	                treeId:"orgTree",
	                view: {
	                    dblClickExpand: false
	                },
	                data: {
	                    simpleData: {
	                        enable: true
	                    }
	                },
	                callback: {
	                   // beforeClick: beforeClick,
	                    onClick: onClick
	                }
            };
            var zNodes;
            $.ajax({  
                   url : common_contextPath+"/organization/searchAllOrg.action",  
                   type : "post", 
                   dataType : "json",  
                   cache : false,  
                   async:false,
                   error : function(textStatus, errorThrown) {  
                       alert("系统ajax交互错误: " + textStatus.value);  
                   },  
                   success : function(data, textStatus) {
                      zNodes = data;
                      $.fn.zTree.init($("#treeDemo"), setting,zNodes);
                   } 
               });             
        	}   
        
	        //查询
	        function gridSearch(){
	            var loginname = jQuery("#loginname").val();
	            var username = jQuery("#username").val();
	            var activeLabel = jQuery("#activeLabel").val();
	            var lockFlagLabel = jQuery("#lockFlagLabel").val();
	            var orgId = jQuery("#orgId").val();
	         
	            var params = {  
	                "loginname" : encodeURIComponent($.trim(loginname)),
	                "username" : encodeURIComponent($.trim(username)),
	                "lockFlag" : encodeURIComponent(lockFlagLabel),
	                "active" : encodeURIComponent(activeLabel),
	                "orgId" : encodeURIComponent(orgId)
	            };
	                
	             //jQuery('#gridTable').appendPostData(params); 如果这个跳转不行的话，就用下面两行，反正亦然，别问为什么，不知道！
	             var postData = $("#gridTable").jqGrid("getGridParam", "postData");
	             $.extend(postData, params);  //(9)将postData中的查询参数覆盖为空值
	            jQuery("#gridTable").jqGrid('setGridParam',
	            {
	                url:common_contextPath+'/system/searchUsers.action'
	            }).trigger("reloadGrid", [{page:1}]); 
	        } 
        	function reload(){
				location.reload();
			}
        
	        //新建
	        function addUser(){
	        	if(tree_sel==null){
					alert("请选择相应树节点进行添加");
				}else{
		            $.dialog({
					        id:'cerify',
					        title:'用户添加', 
					        content:'url:<%=request.getContextPath() %>/system/goAddUser.action?orgId='+tree_sel.id,
					        okVal:false,//确定按钮文字
					        cancelVal:false,//取消按钮文字
					        min:true, //是否显示最小化按钮
					        max:false,//是否显示最大化按钮
					        fixed:false,//开启静止定位
					        lock:true,//开启锁屏
					        focus:true,//弹出窗口后是否自动获取焦点（4.2.0新增）
					        time:null,//设置对话框显示时间
					        resize:true,//是否允许用户调节尺寸
					        drag:true,//是否允许用户拖动位置
					        cache:false,//是否缓存iframe方式加载的窗口内容页
					        width: '650px',
					        height: 550
			        });
		         }
	        }
	        //修改
	        function updateUser(){
	            var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";     
	            if (!ids) {
	                alert("请先选择记录!");  
	                return false;  
	            }
	            if(ids.indexOf(",")!=-1){
	                  alert("只能选择一条记录!");  
	                    return false; 
	            }
	            var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
	            var id = row.userid;//获取选中行的id属性      
	          	$.dialog({
				        id:'cerify',
				       // data:"{'userId':"+id+"}",
				        title:'用户修改', 
				        content:'url:<%=request.getContextPath() %>/system/toUpdateUser.action?testId='+id,
				        okVal:false,//确定按钮文字
				        cancelVal:false,//取消按钮文字
				        min:true, //是否显示最小化按钮
				        max:false,//是否显示最大化按钮
				        fixed:false,//开启静止定位
				        lock:true,//开启锁屏
				        focus:true,//弹出窗口后是否自动获取焦点（4.2.0新增）
				        time:null,//设置对话框显示时间
				        resize:true,//是否允许用户调节尺寸
				        drag:true,//是否允许用户拖动位置
				        cache:false,//是否缓存iframe方式加载的窗口内容页
				        width: '650px',
				        height: 550
		        	});
	        }

	        //清空
	        function reset(){
	            jQuery("#loginname").val("");
	            jQuery("#username").val("");
	            jQuery("#activeLabel").val("");
	            jQuery("#lockFlagLabel").val(""); 
	            jQuery("#citySel").val("--请选择--"); 
	            jQuery("#orgId").val(""); 
	        }
	           //刷新
	        function refresh(){
	            jQuery("#gridTable").jqGrid('setGridParam',
	                    {
	                        url:common_contextPath+'/system/searchUsers.action'
	                    }).trigger("reloadGrid", [{page:1}]); 
	        }
	        function refreshss(){
		        var loginname = jQuery("#loginname").val();
	            var username = jQuery("#username").val();
	            var activeLabel = jQuery("#activeLabel").val();
	            var lockFlagLabel = jQuery("#lockFlagLabel").val();
	            var orgId = jQuery("#orgId").val();
	            var params = {  
	                "loginname" : encodeURIComponent($.trim(loginname)),
	                "username" : encodeURIComponent($.trim(username)),
	                "lockFlag" : encodeURIComponent(lockFlagLabel),
	                "active" : encodeURIComponent(activeLabel),
	                "orgId" : encodeURIComponent(orgId)
	            };
				if((loginname != ""&&loginname != null) ||(username != ""&&username != null) ||(activeLabel != ""&&activeLabel != null)||(lockFlagLabel != ""&&lockFlagLabel != null) ||(orgId != ""&&orgId != null)||tree_sel==null ){
					var postData = $("#gridTable").jqGrid("getGridParam", "postData");
	            	 $.extend(postData, params);  //(9)将postData中的查询参数覆盖为空值
					jQuery("#gridTable").jqGrid('setGridParam',
	                    {
	                        url:common_contextPath+'/system/searchUsers.action'
	                    }).trigger("reloadGrid", [{page:1}]); 
				}else{
					jQuery("#gridTable").jqGrid('setGridParam',
		            {
		                url:common_contextPath+'/system/findUserByOrgId.action?id='+tree_sel.id
		            }).trigger("reloadGrid", [{page:1}]); 
				}
	        }
	        function refreshs(){
	                reset();
	                gridSearch();
	        }
	        function refreshadd(){
	               jQuery("#gridTable").jqGrid('setGridParam',
		            {
		                url:common_contextPath+'/system/findUserByOrgId2.action?id='+tree_sel.id
		            }).trigger("reloadGrid", [{page:1}]); 
	        }
	        //解锁
	        function unLock(){
               var ids = $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
               /**if(ids){
                    var lockIds = [];
                    var idArray = ids.split(',');
                    for(var i=0;i<idArray.length;i++){
                        var id = idArray[i];
                        var row= $("#gridTable").jqGrid("getRowData", id);
                        var nodeId = row['userid'];
                        lockIds.push(nodeId);
                        }   
                    }   */    
                if (!ids) {
                alert("请先选择记录!");  
                   return false;  
                }   
                if(ids.indexOf(",")!=-1){
                  alert("只能选择一条记录!");  
                    return false; 
                }   
               
                var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.      
                var id = row.userid;//获取选中行的id属性        
                if(row.lockFlagLabel=="未锁定"){
                  alert("请选择锁定用户！");
                  return false;
                }
                 if(!confirm("是否需要解锁?")){
                   return false;
                }
               /**  var params = {  
                    "ids": lockIds.join()
                 };*/ 
                var actionUrl = "unLock.action?userId="+id;  
                    $.ajax({  
                        url : actionUrl,  
                        type : "post", 
                        //data : params,  
                        dataType : "json",  
                        cache : false,  
                    error : function(textStatus, errorThrown) {  
                        alert("系统ajax交互错误: " + textStatus.value);  
                    },  
                    success : function(data, textStatus) {  
                        refreshss();  
                        alert("解锁成功！");       
                        
                    }  
                });                       
             }
	        
	        //密码重置
	        function changePsw(){
	               var ids = $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";              
	                if (!ids) {
	                alert("请先选择记录!");  
	                   return false;  
	                } 
	                if(ids.indexOf(",")!=-1){
	                  alert("只能选择一条记录!");  
	                    return false; 
	                }
	                if(!confirm("是否确认重置密码？")){
	                   return false;
	                }
	               var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
	                var id = row.userid;//获取选中行的id属性  
	                var actionUrl = "resetUserPwd.action?userId="+id;  
	                    $.ajax({  
	                        url : actionUrl,  
	                        type : "post", 
	                        dataType : "json",  
	                        cache : false,  
	                    error : function(textStatus, errorThrown) {  
	                        alert("系统ajax交互错误: " + textStatus.value);  
	                    },  
	                    success : function(data, textStatus) {  
	                        refreshss();       
	                        alert("重置成功！");       
	                        
	                    }  
	                });
	        }
	         //查看
	        function searchUser(){
	           var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + ""; 
	           if (!ids) {
	                alert("请先选择记录!");  
	                return false;  
	           }
	           if(ids.indexOf(",")!=-1){
	                  alert("只能选择一条记录!");  
	                    return false; 
	            }
	           var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
	           var id = row.userid;//获取选中行的id属性 
	        	$.dialog({
				        id:'cerify',
				       // data:"{'userId':"+id+"}",
				        title:'用户查看', 
				        content:'url:<%=request.getContextPath() %>/system/searchUserById.action?testId='+id,
				        okVal:false,//确定按钮文字
				        cancelVal:false,//取消按钮文字
				        min:true, //是否显示最小化按钮
				        max:false,//是否显示最大化按钮
				        fixed:false,//开启静止定位
				        lock:true,//开启锁屏
				        focus:true,//弹出窗口后是否自动获取焦点（4.2.0新增）
				        time:null,//设置对话框显示时间
				        resize:true,//是否允许用户调节尺寸
				        drag:true,//是否允许用户拖动位置
				        cache:false,//是否缓存iframe方式加载的窗口内容页
				        width: '650px',
				        height: 670
		        	});
	        }
	      	//导出方法
	        function exportExcel1(){
	 					var cols = getColProperties("gridTable");
	 					alert(cols);
	        			//jQuery("#gridTable").excelExport("../../shujuweihu/shujuweihu_export.action?cols=" + cols);
	        }
	        //获取要导出的列字段
	        function getColProperties(id){var b = jQuery("#"+id)[0];var params = b.p.colModel;var cols = '';for ( var i = 1; i < params.length; i++) { if(!params[i].hidden && params[i].name!='cb'){cols += "," + params[i].name;}}return cols.substring(1,cols.length)}
	        
	        //导入
			function impExcel(){
				var type="eqAction!importPersonData.action";
				var sURL="<%=request.getContextPath() %>/view/file_importecxel.jsp?type="+type;
		   		window.showModalDialog(sURL,"","dialogWidth=400px;dialogHeight=200px;dialogLeft:400xp;dialogTop:100xp");
		    	gridSearch();
			}
			
			//导出excel
	        function exportExcel(){
	                var loginname = encodeURIComponent($.trim(jQuery("#loginname").val()));
	                var username = escape(encodeURIComponent($.trim(jQuery("#username").val())));
	                var active = encodeURIComponent($.trim(jQuery("#activeLabel").val()));
	                var lockFlag = encodeURIComponent($.trim(jQuery("#lockFlagLabel").val()));
	                var orgId = $.trim(jQuery("#orgId").val());
	                window.location.href="exportExcel.action?loginname="+loginname+"&username="+username+"&active="+active+"&orgId="+orgId+"&lockFlag="+lockFlag; 
	        }
         </script>
    </head>
<body>
        	<div>
       		<table width="100%" border="0" cellspacing="0" cellpadding="0">
				  <tr>
				      <td>
						    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="formTableNew">
						      <tr>
							        <td width="6%">用户名：</td>
						        <td width="12%"><input type="text" id="loginname" name="users.oginname" value="" class="search_InputText" style="width:99%;" /></td>
							        <td width="5%" align="right">姓名：</td>
						        <td width="12%"><input type="text" id="username" name="users.username" value=""  class="search_InputText" style="width:99%;" /></td>
							        <td width="7%" align="right">用户状态：</td>
							        <td width="12%">
							        	<select  name="active" id="activeLabel" class="search_InputSelect" style="width:99%;">
								          <option value="" >请选择</option>
	                                      <option value="1">有效</option>
	                                      <option value="0">外出试验</option>   
					        	</select></td>
							        <td width="7%" align="right">锁定状态：</td>
							        <td width="12%">
							        	<select  name="lockFlag" id="lockFlagLabel" class="search_InputSelect" style="width:99%;">
								          <option value="" >请选择</option>
	                                      <option value="1">锁定</option>
	                                      <option value="0">未锁定</option>   
					        	</select></td>
							        <td width="7%" align="right">组织机构：</td>
							        <td width="12%">
							             <input type="hidden" id="orgId" name="orgId" />
			                             <input id="citySel" name="orgNameLabel" type="text"  readonly="readonly" value="--请选择--" style="width: 97%;  align:left; height: 20px; border: 1px #cccccc solid; background: url(img/xia_l.png) no-repeat right center; background-color:#FFFFFF;" onclick="showMenu();" />
			                        	 <div id="menuContent" class="menuContent"
				                            style="display: none; position: absolute;z-index:10000; background:#f0f6e4; border:1px solid #617775; overflow-y:auto; overflow-x:auto;width:180px;">
				                            <ul id="treeDemo" class="ztree"
				                                style="margin-top: 0; width: 170px; height: 200px;z-index:10000;">
				                            </ul>
		                        </div>		                        </td>
							      
						        <td width="7%" align="center"><input type="button" name="button" id="button" value="查询" class="search_Btn" onclick="gridSearch()"/></td>
						        <td width="7%" align="center"><input type="button" name="button2" id="button2" value="清空" class="search_Btn" onclick="reset()"/></td>
					          </tr>
					          
					          
				    </table>				      </td>
			  </tr>
			  
			  <tr>
			    <td align="right" height="9" class="sclinebotBg"></td>
			  </tr>
			  <tr>
			    <td height="10" align="right"></td>
		      </tr>
			</table>
       	</div>
    <table width="100%"  border="0" cellpadding="0" cellspacing="0">
        <tr>
                <td height="379" width="260" valign="top" style="background: #FFFFFF; border: #aaaaaa solid 1px;">
					<div style="font-size:13px;height:30px;padding-top:5px;padding-left:5px;background-image: url(img/tree_l_sc_bg.gif);background-repeat:repeat-x;">组织名称检索：
						<input type="text" id="key" name="organization.orgName" value="" class="empty" style="width:150px; height:16px; line-height:20px;"  />
					</div>
                    <div style="background-image: url('<%=request.getContextPath() %>/jslib/ztree/img/titlie.gif'); background-repeat:repeat-x;height: 20px; width: 265px; padding-top:5px;"> 
                       
                        <span >
                            <img onclick="return false;" src="<%=request.getContextPath() %>/jslib/ztree/img/add.png"  alt="闭合" title="点击关闭所有节点" id="collapseAllBtn"/>
                        </span> 
                        <span >
                            <img onclick="return false;"  src="<%=request.getContextPath() %>/jslib/ztree/img/delete.gif" alt="展开" title="点击展开所有节点"  id="expandAllBtn"/>
                        </span>
                    </div>
                    <div
                        style="WIDTH: 265px; HEIGHT: 480px; OVERFLOW: auto; scrollbar-3dlight-color: #595959; scrollbar-arrow-color: #FFFFFF; scrollbar-base-color: #CFCFCF; scrollbar-darkshadow-color: #FFFFFF; scrollbar-face-color: #CFCFCF; scrollbar-highlight-color: #FFFFFF; scrollbar-shadow-color: #595959">
                        <div id="treeList" class="dtree">
                            <ul id="tree" class="ztree" style="width:230px; overflow:auto;"></ul>
                        </div>
                    </div>
                </td>
                <td valign="top" style="padding-left:10px;">
                    <table width="100%" height="0" border="0" cellpadding="0" cellspacing="0" >
                        <tr>
                            <td height="30" valign="top">
                                <input id="add_user" type='button' value='添 加' onclick="addUser()" class='button_b' />
			                    <input id="edit_user" type='button' value='修 改' onclick="updateUser()" class='button_b' />
			                    <input id="del_user" type='button' value='删 除' onclick='deleteUser()' class='button_b' />
			                    <input id="user_query" type='button' value='查 看' onclick='searchUser()' class='button_b' />
			                    <input type='button' value='刷新' onclick='refreshs()' class='button_b' /> 
			                    <input id="unLock_user" type='button' value='解 锁' onclick='unLock()' class='button_b' />                
			                     <!-- <input id="cerity_user" type='button' value='证 书' onclick='cerity()' class='button_b' />    
			                    <input id="export_user" type='button' value='导入' onclick='impExcel()' class='button_b' />            
			                    <input id="export_user" type='button' value='导出excel' onclick='exportExcel()' class='button_b' />  -->              
	                      		<input id="edit_userpwd" type='button' value='密码重置' onclick='changePsw()' class='button_b' /></td>
                        </tr>
                        <tr>
                            <td>                   
                                <table id="gridTable" style="width:100%;"></table>
                                <div id="gridPager"   style="width:100%;"></div>
                            </td>
                        </tr>
                  </table>
                </td>
      </tr>
</table>
</body>
</html>